home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dragan1r / tack.ctl (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-15  |  3.7 KB  |  107 lines

  1. VERSION 5.00
  2. Begin VB.UserControl PinTack 
  3.    BorderStyle     =   1  'Fixed Single
  4.    CanGetFocus     =   0   'False
  5.    ClientHeight    =   570
  6.    ClientLeft      =   0
  7.    ClientTop       =   0
  8.    ClientWidth     =   285
  9.    ForwardFocus    =   -1  'True
  10.    ScaleHeight     =   38
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   19
  13.    ToolboxBitmap   =   "Tack.ctx":0000
  14.    Begin VB.Image imgNotOnTop 
  15.       Height          =   270
  16.       Left            =   0
  17.       Picture         =   "Tack.ctx":0312
  18.       Top             =   300
  19.       Visible         =   0   'False
  20.       Width           =   285
  21.    End
  22.    Begin VB.Image imgOnTop 
  23.       Height          =   270
  24.       Left            =   0
  25.       Picture         =   "Tack.ctx":078C
  26.       Top             =   0
  27.       Visible         =   0   'False
  28.       Width           =   285
  29.    End
  30. Attribute VB_Name = "PinTack"
  31. Attribute VB_GlobalNameSpace = False
  32. Attribute VB_Creatable = True
  33. Attribute VB_PredeclaredId = False
  34. Attribute VB_Exposed = True
  35. Option Explicit
  36. Dim ParentPosition As Integer
  37. Enum Positions
  38.     Normal
  39.     On_Top
  40. End Enum
  41. Enum Borders
  42.     None
  43.     Fixed
  44. End Enum
  45. Event Change(NewPosition As Integer)
  46. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  47. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  48. Property Get FormPosition() As Positions
  49.     FormPosition = ParentPosition
  50. End Property
  51. Property Let FormPosition(NewPosition As Positions)
  52.     ParentPosition = NewPosition
  53.     PropertyChanged "FormPosition"
  54.     RaiseEvent Change(CInt(NewPosition))
  55.     ShowMode
  56. End Property
  57. Property Get BorderStyle() As Borders
  58.     BorderStyle = UserControl.BorderStyle
  59. End Property
  60. Property Let BorderStyle(NewStyle As Borders)
  61.     UserControl.BorderStyle = NewStyle
  62.     PropertyChanged "BorderStyle"
  63.     UserControl_Resize
  64. End Property
  65. Private Sub UserControl_Click()
  66.     FormPosition = Abs(ParentPosition - 1)
  67.     ShowMode
  68. End Sub
  69. Private Sub UserControl_InitProperties()
  70.     ShowMode
  71. End Sub
  72. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  73.     RaiseEvent MouseDown(Button, Shift, ScaleX(X, ScaleMode, vbContainerPosition), ScaleY(Y, ScaleMode, vbContainerPosition))
  74. End Sub
  75. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  76.     RaiseEvent MouseUp(Button, Shift, ScaleX(X, ScaleMode, vbContainerPosition), ScaleY(Y, ScaleMode, vbContainerPosition))
  77. End Sub
  78. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  79.     ParentPosition = PropBag.ReadProperty("FormPosition", 0)
  80.     UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
  81.     ShowMode
  82. End Sub
  83. Private Sub UserControl_Resize()
  84. Static Started As Boolean
  85.     If Started = True Then Exit Sub
  86.     Started = True
  87.     Addition = UserControl.BorderStyle * UNIT_BORDER
  88.     UserControl.Height = ScaleY(Addition + UNIT_HEIGHT, 3, vbContainerPosition)
  89.     UserControl.Width = ScaleX(Addition + UNIT_WIDTH, 3, vbContainerPosition)
  90.     UserControl.Refresh
  91.     Started = False
  92. End Sub
  93. Sub ShowMode()
  94.     Select Case ParentPosition
  95.         Case Normal
  96.             Picture = imgNotOnTop
  97.             SetWindowPos Parent.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
  98.         Case On_Top
  99.             Picture = imgOnTop
  100.             SetWindowPos Parent.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
  101.     End Select
  102. End Sub
  103. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  104.     PropBag.WriteProperty "FormPosition", ParentPosition, 0
  105.     PropBag.WriteProperty "BorderStyle", UserControl.BorderStyle, 0
  106. End Sub
  107.